using System;
using Mbs.Factories;

namespace Mbs.ComponentModel.Container.Lifestyle
{
    public class LifestyleManagerFactory : RegisterFactory<string,ILifestyleManager>, ILifestyleManagerFactory
    {

        public LifestyleManagerFactory():base(StringComparer.OrdinalIgnoreCase)
        {
            Register(LifestyleType.Singleton, () => new SingletontLifestyleManager());
            Register(LifestyleType.Transient, () => new TransientLifestyleManager());
            Register(LifestyleType.Thread, () => new PerThreadLifestyleManager());
            Register(LifestyleType.GenericSingleton, () => new GenericSingletonLifestyleManager());
            Register(LifestyleType.GenericTransient, () => new GenericTransientLifestyleManager());
        }

       

        public override ILifestyleManager Create(string lifestyleTypeId)
        {
            var result = base.Create(lifestyleTypeId);
            if (result == null)
                result = new SingletontLifestyleManager();
            return result;
        }
    }
}
